package org.gl.training.planner.ws;

import javax.ejb.EJB;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

import org.gl.training.planner.dao.UserDao;
import org.gl.training.planner.model.User;

@WebService(name = "UserService", serviceName = "UserService")
public class UserService {

	@EJB
	private UserDao userDao;

	@WebMethod
	@WebResult(name = "UserInfo")
	public UserInfo getUserInfo(@WebParam(name = "UserId") Integer userId) {
		User user = userDao.find(userId);
		if (user == null) {
			return null;
		}
		UserInfo userInfo = new UserInfo();
		userInfo.setId(userId);
		userInfo.setFullName(user.getFullName());
		userInfo.setUserName(user.getUserName());
		userInfo.setEmail(user.getEmail());
		userInfo.setNotes(user.getNotes());
		return userInfo;
	}

}
